package net.dodoman.miao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Dbaccess {

	public static void insert(String wholeWord, String keyWordInc)
			throws Exception {
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		String dburl = "jdbc:odbc:miao";// 此为ODBC连接方式
		Connection conn = DriverManager.getConnection(dburl);
		Statement stmt = conn.createStatement();
		String sql = "insert into word (WC, KWI) values('" + wholeWord + "','"
				+ keyWordInc + "')";
		// ResultSet rs = stmt.executeQuery("select * from word");
		stmt.executeUpdate(sql);
	}

	@SuppressWarnings("unused")
	public static void get() throws Exception {
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		// String dburl = "jdbc:odbc:driver={Microsoft Access Driver
		// (*.mdb)};DBQ=Miao's HomeWork.mdb";// 此为NO-DSN方式
		String dburl = "jdbc:odbc:miao";// 此为ODBC连接方式
		Connection conn = DriverManager.getConnection(dburl);
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select * from word");
		while (rs.next()) {
			System.out.println(rs.getString(1) + rs.getString(2));
		}
	}
}